﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ZLCMS.Business;
using ZLCMS.Business.DwzFrame;
using ZLCMS.Data.Model;
using NHibernate;

namespace ZLCMS.Web.SystemManage.Basics.Operator
{
    public partial class Add : System.Web.UI.Page
    {
        protected FrameHelper _framePage;

        protected void Page_Load(object sender, EventArgs e)
        {
            _framePage = new FrameHelper(this);
            if (IsPostBack)
            {
                AddOperator();
            }
        }

        protected void AddOperator()
        {
            if (tb_password_1.Text != tb_password_2.Text)
            {
                _framePage.Alert(new ReturnCode() { statusCode = 300, message = "输入的密码不匹配!" });
                return;
            }
            using (ISession session = DotNet.Common.NHibernateUtil.SessionFactoryHelper.CreateSession())
            {
                UserInfo op = new UserInfo();

                op.UserAccount = tb_account.Text;
                op.UserName = tb_username.Text;
                op.Passwd = _password_new.Value;

                session.Save(op);
                session.Flush();
            }

            _framePage.Alert(new ReturnCode()
            {
                statusCode = 200,
                message = "操作成功!",
                callbackType = "closeCurrent",
                navTabId = _framePage.NavTabId
            });
        }
    }
}
